using System;
using System.Windows.Controls;

namespace FluentSilverlight.Expressions.Buttons
{
    public class HyperlinkButtonExpression<TModel> 
        : ButtonBaseExpression<HyperlinkButtonExpression<TModel>, TModel, HyperlinkButton>
        where TModel : class 
    {
        private object content;

        public HyperlinkButtonExpression(TModel model, string content)
            : this(model, string.Format("HyperlinkButton_{0}", Guid.NewGuid()), content)
        {
        }

        public HyperlinkButtonExpression(TModel model, string name, string content)
            : base(model, name)
        {
            this.content = content;
        }

        public HyperlinkButtonExpression<TModel> Content(object value)
        {
            content = value;
            return thisInstance();
        }

        public static implicit operator HyperlinkButton(HyperlinkButtonExpression<TModel> expression)
        {
            var button = new HyperlinkButton();
            expression.BuildUp(button);
            return button;
        }

        protected override void BuildUp(HyperlinkButton element)
        {
            element.Content = content;
        }

        protected override HyperlinkButtonExpression<TModel> thisInstance()
        {
            return this;
        }
    }
}